package com.itheima;

import java.math.BigDecimal;

public class Demo1 {
    public static void main(String[] args) {
        double[] arr = {0.1, 0.2, 2.1, 3.2, 5.56, 7.21};
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }

        String sum2 = String.valueOf(sum);

        BigDecimal bigDecimal = new BigDecimal(sum2);
        System.out.println("总和是：" + bigDecimal);

        BigDecimal num = new BigDecimal(arr.length);
        BigDecimal mean = bigDecimal.divide(num, 2, 2);
        System.out.println("平均值：" + mean);
    }
}
